package com.businessportal.web.controllers.filebrowser;

import com.businessportal.web.ckeditor.filebrowser.CommandDetector;
import com.businessportal.web.ckeditor.filebrowser.CommandProcessor;
import com.businessportal.web.ckeditor.filebrowser.ICommand;
import com.businessportal.web.ckeditor.filebrowser.InitCommand;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by Vadim on 6/27/14.
 */

@WebServlet(urlPatterns = "/securepages/browse.do")
public class FileBrowserController  extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        ICommand cmd = new InitCommand(CommandDetector.CkCommand.Init, CommandDetector.CkContentType.Image);//CommandDetector.getCurrentCommand(req);

        CommandProcessor processor = new CommandProcessor(cmd);

        String retValue = processor.Process();

        resp.setContentType("text/xml");
        resp.setCharacterEncoding("UTF-8");

        resp.getWriter().write(retValue);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
